package com.hs.jhzd.repository;

import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.hs.jhzd.entity.Fingerprint;

@Repository
public interface FingerprintRepository extends JpaRepository<Fingerprint, String> {

  @Query("SELECT u from Fingerprint u where u.lastUpdateTimeStr > :lastSynchronizeTime")
  List<Fingerprint> getFingerprint2Add(@Param("lastSynchronizeTime") Date lastSynchronizeTime);

  @Query("SELECT u from Fingerprint u where rybh= :rybh ")
  List<Fingerprint> findPoliceFingerprintByPoliceId(@Param("rybh") String rybh);

  @Query("SELECT u from Fingerprint u where rybh= :rybh ")
  List<Fingerprint> findPrisonerFingerprintByNumber(@Param("rybh") String rybh);

  @Query("SELECT count(1) from Fingerprint u ")
  int countPrisonerFingerPrintByPrisonId();

  @Query("SELECT count(1) from Fingerprint u ")
  int countPoliceFingerPrintByPrisonId();

  @Query("SELECT u from Fingerprint u  ")
  List<Fingerprint> findPoliceFingerprintByPrisonId(Pageable pageable);

  @Query("SELECT u from Fingerprint u ")
  List<Fingerprint> findPrisonerFingerprintByPrisonId(Pageable pageable);

Optional<Fingerprint> findByRybh(String string);

}
